<!--
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-02-24 17:39:41
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-03-17 14:00:31
 * @FilePath: /XMate-h5/src/components/charts/chartContainer.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="chart-wrapper">
    <div class="chart-header">
      <div class="title-wrapper">
        <h3 class="title">{{ title }}</h3>
        <p v-if="subtitle" class="subtitle">{{ subtitle }}</p>
      </div>
      <slot name="extra"></slot>
    </div>
    <div class="chart-body">
      <slot></slot>
    </div>
  </div>
</template>

<script setup>

defineProps({
  title: {
    type: String,
    required: true
  },
  subtitle: {
    type: String,
    default: ""
  }
});
</script>

<style scoped lang="less">
.chart-wrapper {
  position: relative;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFF 100%);
  border: 1px solid transparent;
  border-radius: 8px;
  background-image: linear-gradient(#fff, #F8FAFF),
                   linear-gradient(90deg, #4080FF 0%, #3CC7FF 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  overflow: hidden;
  height: 100%; // 添加高度100%

  // 底部渐变背景
  &::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0; // 从顶部开始
    bottom: 0; // 延伸到底部
    background: linear-gradient(180deg, 
      rgba(248, 250, 255, 0) 0%,
      rgba(248, 250, 255, 0.3) 50%,
      rgba(248, 250, 255, 0.6) 75%,
      rgba(248, 250, 255, 0.8) 100%
    );
    pointer-events: none;
    z-index: 0;
  }
}

.chart-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  z-index: 1; // 确保在渐变层上方
}

.title-wrapper {
  .title {
    font-size: 16px;
    font-weight: 500;
    color: #1D2129;
    line-height: 24px;
    margin: 0;
  }

  .subtitle {
    font-size: 12px;
    color: #86909C;
    line-height: 20px;
    margin: 0;
  }
}

.chart-body {
  position: relative;
  width: 100%;
  height: calc(100% - 56px);
  z-index: 1; // 确保在渐变层上方
}
</style> 